package com.example.kafka;

import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.kafka.annotation.EnableKafka;
import org.springframework.kafka.annotation.KafkaListener;

/**
 * @author zxs
 * @since 2021/10/11
 */
@SpringBootApplication
@EnableKafka
public class KafkaApplication {

    public static void main(String[] args) {
        SpringApplication.run(KafkaApplication.class, args).registerShutdownHook();
    }

    @KafkaListener(topics = "ds0.t_dict", groupId = "mysql")
    public void consumeTest(ConsumerRecord<Long,Object> record) {
        System.out.println("收到消息:"+record);
        System.out.println("id:" + record.key());
        System.out.println("record:" + record.value());
    }

}
